package main

import (
    "net/http"
    "os/exec"
    "log"
    "fmt"
)

func reLaunch () {
        cmd := exec.Command("sh", "./deploy.sh")
        err := cmd.Start()
        if err != nil {
                log.Fatal(err)
        }
        err = cmd.Wait()
}

func autoDeployServer(w http.ResponseWriter, r *http.Request) {
    fmt.Println("incoming ..." + r.Method)
    if r.Method == "POST" {
        // 判断 playLoad 中的密码如果和预设的一致才执行reLanch函数 此处省略
        reLaunch()
    } else {
        fmt.Println("invalid request .. ")
    }
}

func main () {
    fmt.Println("listening at port 5000 ...")
    http.HandleFunc("/", autoDeployServer)
    http.ListenAndServe(":5000", nil)
}
